﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class Controls_Message : System.Web.UI.UserControl
{
    public bool AutoClear
    {
        get
        {
            if (litAutoClear.Text == "") return true;
            return bool.Parse(litAutoClear.Text);
        }
        set { litAutoClear.Text = value.ToString(); }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (AutoClear)
            Literal1.Text = "";
    }

    public void ShowError(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\ErrorMessage.htm"));
        template = template.Replace("{text}", message);
        Literal1.Text = template;
    }

    public void ShowErrorAndPreventAutoClear(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\ErrorMessage.htm"));
        template = template.Replace("{text}", message);
        Literal2.Text = template;
    }

    public void ShowNormal(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\NormalMessage.htm"));
        template = template.Replace("{text}", message);
        Literal1.Text = template;
    }

    public void ShowNormalAndPreventAutoClear(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\NormalMessage.htm"));
        template = template.Replace("{text}", message);
        Literal2.Text = template;
    }

    public void ShowSuccess(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\SuccessMessage.htm"));
        template = template.Replace("{text}", message);
        Literal1.Text = template;
    }

    public void ShowSuccessAndPreventAutoClear(string message)
    {
        string template = File.ReadAllText(Server.MapPath(@"~\Control\Message\Template\SuccessMessage.htm"));
        template = template.Replace("{text}", message);
        Literal2.Text = template;
    }
}